//
//  HaomaSelectModel.m
//  SSC
//
//  Created by 红沙尘 on 17/6/17.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "HaomaSelectModel.h"

@interface HaomaSelectModel ()
{
    NSMutableArray<HaomaModel *> *haomaArray;
    
    NSString *_wei;
    NSString *_weiId;
    SelectedType _type;
}

@end

@implementation HaomaSelectModel

- (id)initWithWei:(NSString *)wei {
    self = [super init];
    
    if (self) {
        
        _wei = wei;
        
        if ([_wei isEqualToString:@"万位"]) {
            _weiId = @"5";
        } else if ([_wei isEqualToString:@"千位"]) {
            _weiId = @"4";
        } else if ([_wei isEqualToString:@"百位"]) {
            _weiId = @"3";
        } else if ([_wei isEqualToString:@"十位"]) {
            _weiId = @"2";
        } else if ([_wei isEqualToString:@"个位"]) {
            _weiId = @"1";
        }
        
        haomaArray = [[NSMutableArray alloc] init];
        
        for (int i = 0; i < 10; i ++) {
            [haomaArray addObject:[[HaomaModel alloc] initWithNumber:i]];
        }
    }
    
    return self;
}

- (NSMutableArray<HaomaModel *> *)allHaoma {
    return haomaArray;
}

- (BOOL)hasSelectedHaoma {
    
    for (HaomaModel *model in haomaArray) {
        if (model.selected) return YES;
    }
    
    return NO;
}

- (HaomaModel *)haomaAtIndex:(NSInteger)index {
    return haomaArray[index];
}

- (void)changedType:(SelectedType )type {
    _type = type;
}

@end
